#include <stdio.h>
#include <stdlib.h>
#define MAXNUM 30
#define Status int
#define FALSE 0
#define TRUE 1

typedef int ElemType;

typedef struct{
	int arry[MAXNUM];
	int length;
}SqList , *SeqList;

Status InsertSqList (SqList *L , int x , int i)
{

	L->arry[i] = x;
	L->length++;


	return 1;
}

void merge (SqList *L , SqList *M , SqList *N)
{
	int i = 0, j = 0 , k = 0;

	while (i < L->length && j < M->length)
	{
		if(L->arry[i] <= M->arry[j])
		{
			N->arry[k] = L->arry[i];
			k++;
			i++;
		}

		else
		{
			N->arry[k] = M->arry[j];
			k++;
			j++;
		}

		while (i <L->length)
		{
			N->arry[k] = L->arry[i];
			i++;
			k++;
		}
		while (j < M->length)
		{
			N->arry[k] = M->arry[j];
			j++;
			k++;
		}
	}


}

void output (SqList *L)
{
	int len = L->length;
	for (int i = 0 ; i < len ; i++ )
	{
		printf ("%d\n" , L->arry[i]);
	}
}

void init (SqList *L)
{
	L->length = 0;
}


int main ()
{
	SeqList first;
	SeqList second;
	SeqList third;

	init (first);
	init (second);
	init (third);

	int n , m;

	scanf ("%d%d" , &n , &m);

	for (int i = 0 ; i < n ; i++)
	{
		int tem;
		scanf ("%d" , &tem);
		InsertSqList (first , tem , i );
	}

	for (int i = 0 ; i < m ; i++)
	{
		int tem1;
		scanf ("%d" , &tem1);
		InsertSqList (second , tem1 , i );
	}


	merge(first , second ,third);
	output(third);
	return 0;
}